package com.deli.springboot.demoquartz;

import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;
import java.util.List;

public class HelloJob implements Job {
    private static final Logger logger = LoggerFactory.getLogger(HelloJob.class);
    private String message;
    private Float math;
    private Integer triggerInt;

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Float getMath() {
        return math;
    }

    public void setMath(Float math) {
        this.math = math;
    }

    public Integer getTriggerInt() {
        return triggerInt;
    }

    public void setTriggerInt(Integer triggerInt) {
        this.triggerInt = triggerInt;
    }

    @Override
    public void execute(JobExecutionContext context) throws JobExecutionException {
        logger.info("执行------->>>HelloJob任务>>",this.getClass().getName());
        System.out.println("hello world");
        System.out.println(context.getTrigger().getStartTime());
        System.out.println(context.getTrigger().getEndTime());

        //测试jobDateil和trigger的参数
        //test(context);
    }
    private void test(JobExecutionContext context){
        JobKey key = context.getJobDetail().getKey();
        TriggerKey triggerKey = context.getTrigger().getKey();
        JobDataMap jobDataMap = context.getJobDetail().getJobDataMap();
        JobDataMap triggerDateMap = context.getTrigger().getJobDataMap();
        System.out.println(context.getJobDetail().getKey().getName()+"----"+message+"----"+math);
        System.out.println(context.getTrigger().getKey().getName()+"----"+message+"----"+triggerInt);
    }
}
